<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
        	<form class="form-horizontal m" id="form-daily-add">
				<input name="userId"  type="hidden" id="chooseId"/>
				<div class="form-group">
					<label class="col-sm-3 control-label">工作内容：</label>
					<div class="col-sm-8">
						<textarea id="workContent" name="workContent" class="form-control" style="height: 100px;"></textarea>
					</div>
				</div>

				<div class="form-group">
					<label class="col-sm-3 control-label">工作时间：</label>
					<div class="col-sm-3">
						<input id="commonDate" name="workDate" class="form-control" type="text" readonly>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">工作时长：</label>
					<div class="col-sm-3">
						<input id="workHours" name="workHours" class="form-control" type="number">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">审批人：</label>
					<div class="col-sm-3">
						<input class="form-control" type="text" name="userName" onclick="chooseUser()" readonly="true" id="chooseName">
					</div>
				</div>
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">是否加班：</label>-->
					<!--<div class="col-sm-8">-->
						<!--<div class="onoffswitch">-->
							<!--<input type="checkbox" th:checked="false" onclick="overtime(this)" class="onoffswitch-checkbox" id="workOvertime" name="workOvertime">-->
							<!--<label class="onoffswitch-label" for="workOvertime">-->
								<!--<span class="onoffswitch-inner"></span>-->
								<!--<span class="onoffswitch-switch"></span>-->
							<!--</label>-->
						<!--</div>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">加班内容：</label>-->
					<!--<div class="col-sm-8">-->
						<!--<textarea id="overtimeContent" name="overtimeContent" class="form-control" style="height: 100px;" disabled></textarea>-->
					<!--</div>-->
				<!--</div>-->
				<!--<div class="form-group">-->
					<!--<label class="col-sm-3 control-label">加班时长：</label>-->
					<!--<div class="col-sm-3">-->
						<!--<input id="overtimeHours" name="overtimeHours" class="form-control" type="number" disabled >-->
					<!--</div>-->
				<!--</div>-->
				<div class="form-group">
					<label class="col-sm-3 control-label">备注：</label>
					<div class="col-sm-8">
						<textarea id="remark" name="remark" class="form-control" style="height: 100px;"></textarea>
					</div>
				</div>
				<div class="form-group">
					<div class="form-control-static col-sm-offset-9">
						<button type="submit" class="btn btn-primary">提交</button>
						<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
					</div>
				</div>
			</form>
		</div>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
    <script type="text/javascript">

        // function overtime(obj) {
        //     if(obj.checked){
        //         $("#overtimeContent").attr("disabled",false);
        //         $("input[name='overtimeHours']").prop("disabled",false);
			// }else{
        //         $("#overtimeContent").attr("disabled",true);
        //         $("input[name='overtimeHours']").prop("disabled",true);
        //         $("#overtimeContent").val("");
        //         $("input[name='overtimeHours']").val("");
			// }
        //     console.log(obj.checked)
        // }

		var prefix = ctx + "module/daily"
		$("#form-daily-add").validate({
			rules:{
                workContent:{
					required:true,
                    minlength: 5,
                    maxlength: 500
				},
                workDate :{
                    required:true
				},
                workHours :{
                    required:true,
                    maxlength: 20
				},
                // overtimeContent:{
                 //    required:true,
                 //    maxlength: 500
				// },
                // overtimeHours :{
                 //    required:true,
                 //    maxlength: 20
				// }
			},
            messages:{

			},
			submitHandler: function(form) {
				// $.operate.save(prefix + "/add", $('#form-daily-add').serialize());
				add();
			}
		});
		function add() {
            var workContent = $("#workContent").val();
            var workDate = $("input[name='workDate']").val();
            var workHours = $("input[name='workHours']").val();
            var userId = $("input[name='userId']").val();
            // var workOvertime = $("input[name='workOvertime']").is(':checked') == true ? 1 : 0;
            // var overtimeContent = $("#overtimeContent").val();
            // var overtimeHours = $("input[name='overtimeHours']").val();
            var remark = $("#remark").val();
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/add",
                data : {
                    "workContent": workContent,
                    "workDate": workDate,
                    "workHours": workHours,
					"userId":userId,
                    // "workOvertime": workOvertime,
                    // "overtimeContent": overtimeContent,
                    // "overtimeHours": overtimeHours,
					"remark":remark
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.saveSuccess(data);
                }
            });
        }
        function chooseUser() {
            var url = ctx + "system/user/chooseUser/";
            $.modal.open("选择审批人", url, '600', '380');
        }

	</script>
</body>
</html>
